//
//  NSObject+HDMyCommunityModel.m
//  app
//
//  Created by D on 15/8/20.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HDMyCommunityModel.h"

@implementation HDMyCommunityModel

-(instancetype)initWithDict:(NSDictionary *)dict
{
    if (self  = [super init]) {
        
        self.house_id = dict[@"id"];
        self.cmid = dict[@"cmid"];
        self.community_name = dict[@"community_name"];
        self.house_name = dict[@"house_name"];
        self.selected = dict[@"selected"];
        
        if (self.selected.integerValue == 1) {
            NSString * fullAddress = [NSString stringWithFormat:@"%@,%@",self.community_name,self.house_name];
            
            NSArray *array = [self.house_name componentsSeparatedByString:@","];
            
            NSString * house_name = [array objectAtIndex:0];
            
            [[NSUserDefaults standardUserDefaults] setObject:fullAddress forKey:@"fullAddress"];
//            [[NSUserDefaults standardUserDefaults] setObject:self.community_name forKey:kMyAreaTitle];
            [[NSUserDefaults standardUserDefaults] setObject:house_name forKey:kMyAreaTitle];
            [[NSUserDefaults standardUserDefaults] setObject:self.cmid forKey:kMyAreaID];
            [[NSUserDefaults standardUserDefaults] synchronize];
        }
 
    }
    
    return self;
}

+(instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc]initWithDict:dict];
}

@end
